home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 3 / Cream of the Crop 3.iso / sound / ptmid.zip / MOD-FORM.TXT < prev    next >
Text File  |  1994-01-05  |  20KB  |  384 lines

  1. Noisetracker/Soundtracker/Protracker Module Format
  2. --------------------------------------------------
  3. Credits:  Lars Hamre, Norman Lin, Mark Cox, Peter Hanning,
  4.           Steinar Midtskogen, Marc Espie, and Thomas Meyer
  5. (All numbers below are given in decimal)
  6.           3rd Revision
  7.  
  8. Module Format:
  9. # Bytes   Description
  10. -------   -----------
  11. 20        The module's title, padded with null (\0) bytes. Original
  12.           Protracker wrote letters only in uppercase.
  13.  
  14. (Data repeated for each sample 1-15 or 1-31)
  15. 22        Sample's name, padded with null bytes. If a name begins with a
  16.           '#', it is assumed not to be an instrument name, and is
  17.           probably a message.
  18. 2         Sample length in words (1 word = 2 bytes). The first word of
  19.           the sample is overwritten by the tracker, so a length of 1
  20.           still means an empty sample. See below for sample format.
  21. 1         Lowest four bits represent a signed nibble (-8..7) which is
  22.           the finetune value for the sample. Each finetune step changes
  23.           the note 1/8th of a semitone. Implemented by switching to a
  24.           different table of period-values for each finetune value.
  25. 1         Volume of sample. Legal values are 0..64. Volume is the linear
  26.           difference between sound intensities. 64 is full volume, and
  27.           the change in decibels can be calculated with 20*log10(Vol/64)
  28. 2         Start of sample repeat offset in words. Once the sample has
  29.           been played all of the way through, it will loop if the repeat
  30.           length is greater than one. It repeats by jumping to this
  31.           position in the sample and playing for the repeat length, then
  32.           jumping back to this position, and playing for the repeat
  33.           length, etc.
  34. 2         Length of sample repeat in words. Only loop if greater than 1.
  35. (End of this sample's data.. each sample uses the same format and they
  36.  are stored sequentially)
  37. N.B. All 2 byte lengths are stored with the Hi-byte first, as is usual
  38.      on the Amiga (big-endian format).
  39.  
  40. 1         Number of song positions (ie. number of patterns played
  41.           throughout the song). Legal values are 1..128.
  42. 1         Historically set to 127, but can be safely ignored.
  43.           Noisetracker uses this byte to indicate restart position -
  44.           this has been made redundant by the 'Position Jump' effect.
  45. 128       Pattern table: patterns to play in each song position (0..127)
  46.           Each byte has a legal value of 0..63 (note the Protracker
  47.           exception below). The highest value in this table is the
  48.           highest pattern stored, no patterns above this value are
  49.           stored.
  50. (4)       The four letters "M.K." These are the initials of
  51.           Unknown/D.O.C. who changed the format so it could handle 31
  52.           samples (sorry.. they were not inserted by Mahoney & Kaktus).
  53.           Startrekker puts "FLT4" or "FLT8" here to indicate the # of
  54.           channels. If there are more than 64 patterns, Protracker will
  55.           put "M!K!" here. You might also find: "6CHN" or "8CHN" which
  56.           indicate 6 or 8 channels respectively. If no letters are here,
  57.           then this is the start of the pattern data, and only 15
  58.           samples were present.
  59.  
  60. (Data repeated for each pattern:)
  61. 1024      Pattern data for each pattern (starting at 0).
  62. (Each pattern has same format and is stored in numerical order.
  63.  See below for pattern format)
  64.  
  65. (Data repeated for each sample:)
  66. xxxxxx    The maximum size of a sample is 65535 words. Each sample is
  67.           stored as a collection of bytes (length of a sample was given
  68.           previously in the module). Each byte is a signed value (-128
  69.           ..127) which is the channel data. When a sample is played at a
  70.           pitch of C2 (see below for pitches), about 8287 bytes of
  71.           sample data are sent to the channel per second. Multiply the
  72.           rate by the twelfth root of 2 (=1.0595) for each semitone
  73.           increase in pitch eg. moving the pitch up 1 octave doubles the
  74.           rate. The data is stored in the order it is played (eg. first
  75.           byte is first byte played). The first word of the sample data
  76.           is used to hold repeat information, and will overwrite any
  77.           sample data that is there (but it is probably safer to set it
  78.           to 0).
  79.           The rate given above (8287) conveys an inaccurate picture of
  80.           the module-format - in reality it is different for different
  81.           Amigas. As the routines for playing were written to run off
  82.           certain interrupts, for different Amiga computers the rate to
  83.           send data to the channel will be different. For PAL machines
  84.           the clock rate is 7093789.2 Hz and for NTSC machines it is
  85.           7159090.5 Hz. When the clock rate is divided by twice the
  86.           period number for the pitch it will give the rate to send the
  87.           data to the channel, eg. for a PAL machine sending a note at
  88.           C2 (period 428), the rate is 7093789.2/856 ~= 8287.1369
  89. (Each sample is stored sequentially)
  90.  
  91. Pattern Format:
  92. Each pattern is divided into 64 divisions. By allocating different
  93. tempos for each pattern and spacing the notes across different amounts
  94. of divisions, different bar sizes can be accommodated.
  95.  
  96. Each division contains the data for each channel (1..4) stored after
  97. each other. Channels 1 and 4 are on the left, and channels 2 and 3 are
  98. on the right. In the case of more channels: channels 5 and 8 are on the
  99. left, and channels 6 and 7 are on the right, etc. Each channel's data in
  100. the division has an identical format which consists of 2 words (4
  101. bytes). Divisions are numbered 0..63. Each division may be divided into
  102. a number of ticks (see 'set speed' effect below).
  103.  
  104. Channel Data:
  105.                   (the four bytes of channel data in a pattern division)
  106. 7654-3210 7654-3210 7654-3210 7654-3210
  107. wwww xxxxxxxxxxxxxx yyyy zzzzzzzzzzzzzz
  108.  
  109.     wwwwyyyy (8 bits) is the sample for this channel/division
  110. xxxxxxxxxxxx (12 bits) is the sample's period (or effect parameter)
  111. zzzzzzzzzzzz (12 bits) is the effect for this channel/division
  112.  
  113. If there is to be no new sample to be played at this division on this
  114. channel, then the old sample on this channel will continue, or at least
  115. be "remembered" for any effects. If the sample is 0, then the previous
  116. sample on that channel is used. Only one sample may play on a channel at
  117. a time, so playing a new sample will cancel an old one - even if there
  118. has been no data supplied for the new sample. Though, if you are using a
  119. "silence" sample (ie. no data, only used to turn off other samples) it
  120. is polite to set its default volume to 0.
  121.  
  122. To determine what pitch the sample is to be played on, look up the
  123. period in a table, such as the one below (for finetune 0). If the period
  124. is 0, then the previous period on that channel is used. Unfortunately,
  125. some modules do not use these exact values. It is best to do a binary-
  126. search (unless you use the period as the offset of an array of notes..
  127. expensive), especially if you plan to use periods outside the "standard"
  128. range. Periods are the internal representation of the pitch, so effects
  129. that alter pitch (eg. sliding) alter the period value (see "effects"
  130. below).
  131.  
  132.           C    C#   D    D#   E    F    F#   G    G#   A    A#   B
  133. Octave 1: 856, 808, 762, 720, 678, 640, 604, 570, 538, 508, 480, 453
  134. Octave 2: 428, 404, 381, 360, 339, 320, 302, 285, 269, 254, 240, 226
  135. Octave 3: 214, 202, 190, 180, 170, 160, 151, 143, 135, 127, 120, 113
  136.  
  137. Octave 0:1712,1616,1525,1440,1357,1281,1209,1141,1077,1017, 961, 907
  138. Octave 4: 107, 101,  95,  90,  85,  80,  76,  71,  67,  64,  60,  57
  139.  
  140. Octaves 0 and 4 are NOT standard, so don't rely on every tracker being
  141. able to play them, or even not crashing if being given them - it's just
  142. nice that if you can code it, to allow them to be read.
  143.  
  144. Effects:
  145. Effects are written as groups of 4 bits, eg. 1871 = 7 * 256 + 4 * 16 +
  146. 15 = [7][4][15]. The high nibble (4 bits) usually determines the effect,
  147. but if it is [14], then the second nibble is used as well.
  148.  
  149. [0]: Arpeggio
  150.      Where [0][x][y] means "play note, note+x semitones, note+y
  151.      semitones, then return to original note". The fluctuations are
  152.      carried out evenly spaced in one pattern division. They are usually
  153.      used to simulate chords, but this doesn't work too well. They are
  154.      also used to produce heavy vibrato. A major chord is when x=4, y=7.
  155.      A minor chord is when x=3, y=7.
  156.  
  157. [1]: Slide up
  158.      Where [1][x][y] means "smoothly decrease the period of current
  159.      sample by x*16+y after each tick in the division". The
  160.      ticks/division are set with the 'set speed' effect (see below). If
  161.      the period of the note being played is z, then the final period
  162.      will be z - (x*16 + y)*(ticks - 1). As the slide rate depends on
  163.      the speed, changing the speed will change the slide. You cannot
  164.      slide beyond the note B3 (period 113).
  165.  
  166. [2]: Slide down
  167.      Where [2][x][y] means "smoothly increase the period of current
  168.      sample by x*16+y after each tick in the division". Similar to [1],
  169.      but lowers the pitch. You cannot slide beyond the note C1 (period
  170.      856).
  171.  
  172. [3]: Slide to note
  173.      Where [3][x][y] means "smoothly change the period of current sample
  174.      by x*16+y after each tick in the division, never sliding beyond
  175.      current period". The period-length in this channel's division is a
  176.      parameter to this effect, and hence is not played. Sliding to a
  177.      note is similar to effects [1] and [2], but the slide will not go
  178.      beyond the given period, and the direction is implied by that
  179.      period. If x and y are both 0, then the old slide will continue.
  180.  
  181. [4]: Vibrato
  182.      Where [4][x][y] means "oscillate the sample pitch using a
  183.      particular waveform with amplitude y/16 semitones, such that (x *
  184.      ticks)/64 cycles occur in the division". The waveform is set using
  185.      effect [14][4]. By placing vibrato effects on consecutive
  186.      divisions, the vibrato effect can be maintained. If either x or y
  187.      are 0, then the old vibrato values will be used.
  188.  
  189. [5]: Continue 'Slide to note', but also do Volume slide
  190.      Where [5][x][y] means "either slide the volume up x*(ticks - 1) or
  191.      slide the volume down y*(ticks - 1), at the same time as continuing
  192.      the last 'Slide to note'". It is illegal for both x and y to be
  193.      non-zero. You cannot slide outside the volume range 0..64. The
  194.      period-length in this channel's division is a parameter to this
  195.      effect, and hence is not played.
  196.  
  197. [6]: Continue 'Vibrato', but also do Volume slide
  198.      Where [6][x][y] means "either slide the volume up x*(ticks - 1) or
  199.      slide the volume down y*(ticks - 1), at the same time as continuing
  200.      the last 'Vibrato'". It is illegal for both x and y to be non-zero.
  201.      You cannot slide outside the volume range 0..64.
  202.  
  203. [7]: Tremolo
  204.      Where [7][x][y] means "oscillate the sample volume using a
  205.      particular waveform with amplitude y*(ticks - 1), such that (x *
  206.      ticks)/64 cycles occur in the division". The waveform is set using
  207.      effect [14][7]. Similar to [4].
  208.  
  209. [8]: -- Unused --
  210.  
  211. [9]: Set sample offset
  212.      Where [9][x][y] means "play the sample from offset x*4096 + y*256".
  213.      The offset is measured in words. If no sample is given, yet one is
  214.      still playing on this channel, it should be retriggered to the new
  215.      offset using the current volume.
  216.  
  217. [10]: Volume slide
  218.      Where [10][x][y] means "either slide the volume up x*(ticks - 1) or
  219.      slide the volume down y*(ticks - 1)". If both x and y are non-zero,
  220.      then the y value is ignored (assumed to be 0). You cannot slide
  221.      outside the volume range 0..64.
  222.  
  223. [11]: Position Jump
  224.      Where [11][x][y] means "stop the pattern after this division, and
  225.      continue the song at song-position x*16+y". This shifts the
  226.      'pattern-cursor' in the pattern table (see above). Legal values for
  227.      x*16+y are from 0 to 127.
  228.  
  229. [12]: Set volume
  230.      Where [12][x][y] means "set current sample's volume to x*16+y".
  231.      Legal volumes are 0..64.
  232.  
  233. [13]: Pattern Break
  234.      Where [13][x][y] means "stop the pattern after this division, and
  235.      continue the song at the next pattern at division x*10+y" (the 10
  236.      is not a typo). Legal divisions are from 0 to 63 (note Protracker
  237.      exception above).
  238.  
  239. [14][0]: Set filter on/off
  240.      Where [14][0][x] means "set sound filter ON if x is 0, and OFF is x
  241.      is 1". This is a hardware command for some Amigas, so if you don't
  242.      understand it, it is better not to use it.
  243.  
  244. [14][1]: Fineslide up
  245.      Where [14][1][x] means "decrement the period of the current sample
  246.      by x". The incrementing takes place at the beginning of the
  247.      division, and hence there is no actual sliding. You cannot slide
  248.      beyond the note B3 (period 113).
  249.  
  250. [14][2]: Fineslide down
  251.      Where [14][2][x] means "increment the period of the current sample
  252.      by x". Similar to [14][1] but shifts the pitch down. You cannot
  253.      slide beyond the note C1 (period 856).
  254.  
  255. [14][3]: Set glissando on/off
  256.      Where [14][3][x] means "set glissando ON if x is 1, OFF if x is 0".
  257.      Used in conjunction with [3] ('Slide to note'). If glissando is on,
  258.      then 'Slide to note' will slide in semitones, otherwise will
  259.      perform the default smooth slide.
  260.  
  261. [14][4]: Set vibrato waveform
  262.      Where [14][4][x] means "set the waveform of succeeding 'vibrato'
  263.      effects to wave #x". [4] is the 'vibrato' effect.  Possible values
  264.      for x are:
  265.           0 - sine (default)      /\    /\     (2 cycles shown)
  266.           4  (without retrigger)     \/    \/
  267.  
  268.           1 - ramp down          | \   | \
  269.           5  (without retrigger)     \ |   \ |
  270.  
  271.           2 - square             ,--,  ,--,
  272.           6  (without retrigger)    '--'  '--'
  273.  
  274.           3 - random: a random choice of one of the above.
  275.           7  (without retrigger)
  276.      If the waveform is selected "without retrigger", then it will not
  277.      be retriggered from the beginning at the start of each new note.
  278.  
  279. [14][5]: Set finetune value
  280.      Where [14][5][x] means "sets the finetune value of the current
  281.      sample to the signed nibble x". x has legal values of 0..15,
  282.      corresponding to signed nibbles 0..7,-8..-1 (see start of text for
  283.      more info on finetune values).
  284.  
  285. [14][6]: Loop pattern
  286.      Where [14][6][x] means "set the start of a loop to this division if
  287.      x is 0, otherwise after this division, jump back to the start of a
  288.      loop and play it another x times before continuing". If the start
  289.      of the loop was not set, it will default to the start of the
  290.      current pattern. Hence 'loop pattern' cannot be performed across
  291.      multiple patterns. Note that loops do not support nesting, and you
  292.      may generate an infinite loop if you try to nest 'loop pattern's.
  293.  
  294. [14][7]: Set tremolo waveform
  295.      Where [14][7][x] means "set the waveform of succeeding 'tremolo'
  296.      effects to wave #x". Similar to [14][4], but alters effect [7] -
  297.      the 'tremolo' effect.
  298.  
  299. [14][8]: -- Unused --
  300.  
  301. [14][9]: Retrigger sample
  302.      Where [14][9][x] means "trigger current sample every x ticks in
  303.      this division". If x is 0, then no retriggering is done (acts as if
  304.      no effect was chosen), otherwise the retriggering begins on the
  305.      first tick and then x ticks after that, etc.
  306.  
  307. [14][10]: Fine volume slide up
  308.      Where [14][10][x] means "increment the volume of the current sample
  309.      by x". The incrementing takes place at the beginning of the
  310.      division, and hence there is no sliding. You cannot slide beyond
  311.      volume 64.
  312.  
  313. [14][11]: Fine volume slide down
  314.      Where [14][11][x] means "decrement the volume of the current sample
  315.      by x". Similar to [14][10] but lowers volume. You cannot slide
  316.      beyond volume 0.
  317.  
  318. [14][12]: Cut sample
  319.      Where [14][12][x] means "after the current sample has been played
  320.      for x ticks in this division, its volume will be set to 0". This
  321.      implies that if x is 0, then you will not hear any of the sample.
  322.      If you wish to insert "silence" in a pattern, it is better to use a
  323.      "silence"-sample (see above) due to the lack of proper support for
  324.      this effect.
  325.  
  326. [14][13]: Delay sample
  327.      Where [14][13][x] means "do not start this division's sample for
  328.      the first x ticks in this division, play the sample after this".
  329.      This implies that if x is 0, then you will hear no delay, but
  330.      actually there will be a VERY small delay. Note that this effect
  331.      only influences a sample if it was started in this division.
  332.  
  333. [14][14]: Delay pattern
  334.      Where [14][14][x] means "after this division there will be a delay
  335.      equivalent to the time taken to play x divisions after which the
  336.      pattern will be resumed". The delay only relates to the
  337.      interpreting of new divisions, and all effects and previous notes
  338.      continue during delay.
  339.  
  340. [14][15]: Invert loop
  341.      Where [14][15][x] means "if x is greater than 0, then play the
  342.      current sample's loop upside down at speed x". Each byte in the
  343.      sample's loop will have its sign changed (negated). It will only
  344.      work if the sample's loop (defined previously) is not too big. The
  345.      speed is based on an internal table.
  346.  
  347. [15]: Set speed
  348.      Where [15][x][y] means "set speed to x*16+y". Though it is nowhere
  349.      near that simple. Let z = x*16+y. Depending on what values z takes,
  350.      different units of speed are set, there being two: ticks/division
  351.      and beats/minute (though this one is only a label and not strictly
  352.      true). If z=0, then what should technically happen is that the
  353.      module stops, but in practice it is treated as if z=1, because
  354.      there is already a method for stopping the module (running out of
  355.      patterns). If z<=32, then it means "set ticks/division to z"
  356.      otherwise it means "set beats/minute to z" (convention says that
  357.      this should read "If z<32.." but there are some composers out there
  358.      that defy conventions). Default values are 6 ticks/division, and
  359.      125 beats/minute (4 divisions = 1 beat). The beats/minute tag is
  360.      only meaningful for 6 ticks/division. To get a more accurate view
  361.      of how things work, use the following formula:
  362.                              24 * beats/minute
  363.           divisions/minute = -----------------
  364.                               ticks/division
  365.      Hence divisions/minute range from 24.75 to 6120, eg. to get a value
  366.      of 2000 divisions/minute use 3 ticks/division and 250 beats/minute.
  367.      If multiple "set speed" effects are performed in a single division,
  368.      the ones on higher-numbered channels take precedence over the ones
  369.      on lower-numbered channels. This effect has a large number of
  370.      different implementations, but the one described here has the
  371.      widest usage.
  372.  
  373. N.B. This document should be fairly accurate now, but as the module
  374. format is more of an observation than a standard, a couple of effects
  375. cannot be relied upon to act exactly the same from tracker to tracker
  376. (especially if the tracker is not for the Amiga). It is probably better
  377. to use this document as a guide rather than as a hard-and-fast
  378. definition of the module format. Oh.. and yes, I would normally give
  379. bytes as hex values, but it is easier to understand a consistent
  380. notation.
  381.  
  382. Andrew Scott (Adrenalin Software), INTERNET:ascott@tartarus.uwa.edu.au
  383. Author of MIDIMOD (MOD to MIDI converter), PTMID (MIDI to MOD converter)
  384.